#pragma once
#include <jdbc/cppconn/statement.h>
#include <jdbc/cppconn/resultset.h>
#include <jdbc/cppconn/exception.h>
#include <jdbc/mysql_driver.h>
#include <iostream>
#include <map>
#include <sstream>
using namespace std;
using namespace sql;
class MysqlManager
{
private:
	static MysqlManager* instance;
	mysql::MySQL_Driver* driver;
	Connection* connection;
	Statement* stmt = nullptr;
	ResultSet* res = nullptr;
	string host_name;
	string port;
	string user_name;
	string user_password;
	MysqlManager(string& host_name, string& port, string& user_name, string& user_password);
public:
	~MysqlManager();
	static MysqlManager* get_instance();
	void create_driver();
	void creaete_connection();
	Statement* get_statement();
	void get_qurey_result(string& sql);
	void traverse_result_set();
	ResultSet* getRes()const;
};
class Menu
{
public:
	static void print_info();
	static void print_menu();
};
class Friend
{
public:
	string name;
	string phone;
	string address;
	void get_friend_info();
	void add_friend();
	void del_friend();
	void modify_friend();
};
class Client
{
private:
	Menu menu;
	map<string, Friend> cache;
	static Client* instance;
	Client();
public:
	static Client* get_instance();
	~Client();
	void operator()();
	void set_cache(ResultSet* res);
	map<string, Friend>& get_cache();
};